using NExt.Serialization;

namespace NExt.Core.Validator
{
    public class Length : ValidatorScript
    {
        private const string FUNCTION_NAME = "Length";

        private Length(params string[] parameterNames)
            : base(FUNCTION_NAME, parameterNames)
        {
        }

        public static Length Create(string message, int lengthValue)
        {
            string serializedMessage = JsonSerializer.Serialize(message);
            string serializedLenghtValue = JsonSerializer.Serialize(lengthValue);
            string parameter = string.Format("{0},{1}", serializedMessage, serializedLenghtValue);
            Length length = new Length(parameter);
            return length;
        }

        public static Length Create(int length)
        {
            return Create(null, length);
        }
    }
}